// file-server
function play(a, filename, base_path, doc_type) {
  $.ajax({
    // url: '{% url "file:file" %}',
    url: "/file/",
    type: "POST",
    data: { base_path: base_path, doc_type: doc_type, filename: filename },
    success: function (e) {
      if (e["status"] == 1) {
        $(".right").html("<textarea readonly='readonly' id='text' rows='40' cols='120'></textarea>");
        $("#text").val(e["text"]);
      } else if (e["status"] == 3) {
        $(".right").html(e["text"]);
      } else if (e["status"] == 4) {
        $(".right").html(e["text"]);
      } else {
        $(".right").html("<textarea readonly='readonly' id='text' rows='40' cols='120'></textarea>");
        $("#text").val(e["text"]);
      }
    },
  });
}
function open_dir(a, dirname, base_path, doc_type) {
  var myForm = document.createElement("form");
  // myForm.setAttribute('action', '{% url "file:file" %}');
  myForm.setAttribute("action", "/file/");
  myForm.setAttribute("method", "post");
  var myInput02 = document.createElement("input");
  myInput02.setAttribute("type", "text");
  myInput02.setAttribute("value", base_path);
  myInput02.setAttribute("name", "base_path");
  myForm.appendChild(myInput02);
  var myInput01 = document.createElement("input");
  myInput01.setAttribute("type", "text");
  myInput01.setAttribute("value", doc_type);
  myInput01.setAttribute("name", "doc_type");
  myForm.appendChild(myInput01);
  var myInput = document.createElement("input");
  myInput.setAttribute("type", "text");
  myInput.setAttribute("value", dirname);
  myInput.setAttribute("name", "dirname");
  myForm.appendChild(myInput);
  document.body.appendChild(myForm);
  myForm.submit();
  document.body.removeChild(myForm);
}
function download_file(a, filename, base_path, doc_type) {
  var myForm = document.createElement("form");
  // myForm.setAttribute('action', '{% url "file:file" %}');
  myForm.setAttribute("action", "/file/");
  myForm.setAttribute("method", "post");
  var myInput02 = document.createElement("input");
  myInput02.setAttribute("type", "text");
  myInput02.setAttribute("value", base_path);
  myInput02.setAttribute("name", "base_path");
  myForm.appendChild(myInput02);
  var myInput01 = document.createElement("input");
  myInput01.setAttribute("type", "text");
  myInput01.setAttribute("value", doc_type);
  myInput01.setAttribute("name", "doc_type");
  myForm.appendChild(myInput01);
  var myInput = document.createElement("input");
  myInput.setAttribute("type", "text");
  myInput.setAttribute("value", filename);
  myInput.setAttribute("name", "filename");
  myForm.appendChild(myInput);
  document.body.appendChild(myForm);
  myForm.submit();
  document.body.removeChild(myForm);
}
